package com.elong.businesstravel.entitys;

import java.io.Serializable;
import java.util.Calendar;

import android.R.string;

import com.android.support.jhf.utils.DateUtils;

/**
 * 火车票查询条件类
 * 
 * @author lenovo
 * 
 */
public class TicketSearchCondition implements Serializable {

	public String startStation;
	public String endStation;
	public String startDate;// 必填 出发日期 （线上购票，需要限制在20天内）,
							// 采用yyyyMMdd格式（日期均采用此格式）
	public String trainType;// 0(全部)、1(动车)、2（高铁)、3(普快)等
							// 若查询动车和高铁，则参数传：trainType=1,2
	public String hasYp;// 0，查询所有；1：只查询有票

	/**
	 * 返回出发时间，根据index
	 * 
	 * @param index
	 * @return
	 */
	public String getStartDateByIndex(int index) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTimeInMillis(DateUtils.getDateMillis(startDate, "yyyyMMdd"));
		calendar.add(Calendar.DAY_OF_YEAR, index);
		String startDateString = DateUtils.dateFormat(
				calendar.getTimeInMillis(), "yyyyMMdd");
		return startDateString;
	}
	
	/**
	 * 返回出发时间
	 * @param index
	 * @param pattern
	 * @return
	 */
	public String getStartDateByIndex(int index, String pattern) {
		String startDateString = getStartDateByIndex(index);
		startDateString = DateUtils.dateFormat(startDateString, "yyyyMMdd", pattern);
		return startDateString;
	}

	public String getStartStation() {
		return startStation;
	}

	public void setStartStation(String startStation) {
		this.startStation = startStation;
	}

	public String getEndStation() {
		return endStation;
	}

	public void setEndStation(String endStation) {
		this.endStation = endStation;
	}

	public String getStartDate() {
		return startDate;
	}

	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	public String getTrainType() {
		return trainType;
	}

	public void setTrainType(String trainType) {
		this.trainType = trainType;
	}

	public String getHasYp() {
		return hasYp;
	}

	public void setHasYp(String hasYp) {
		this.hasYp = hasYp;
	}

}
